package com.cyh.testdesignpattern.strategy;

import android.util.Log;

//鸭子
public abstract class Duck {

    FlyBehavior flyBehavior;
    QuackBehavior quackBehavior;

    public abstract void display();

    public void swim() {
        Log.i("Duck", "鸭子都会游泳。。。");
    }

    public void fly() {
        if(flyBehavior != null) {
            flyBehavior.fly();
        }
    }

    public void quack() {
        if(quackBehavior != null) {
            quackBehavior.quack();
        }
    }



    public FlyBehavior getFlyBehavior() {
        return flyBehavior;
    }

    public void setFlyBehavior(FlyBehavior flyBehavior) {
        this.flyBehavior = flyBehavior;
    }

    public QuackBehavior getQuackBehavior() {
        return quackBehavior;
    }

    public void setQuackBehavior(QuackBehavior quackBehavior) {
        this.quackBehavior = quackBehavior;
    }
}
